package request.worker;

import java.util.HashMap;

import net.sf.json.JSONObject;
import net.sf.json.JSONArray;

import soar.basic.*;

import request.share.*;

public class HELLO
{
    private static final String __CLASS__=HELLO.class.getName();

    public String call(JSONObject request)
    {
        String msg;
        try
        {
            msg=request.getString("msg");
            if(msg.isEmpty())
            {
                Errlog.add(__CLASS__+": msg(%s) is empty");
                HashMap<String,String> m=new HashMap<String,String>();
                m.put("errcode", SOAR_ERR.PARA);
                return  JSONObject.fromObject(m).toString();
            }
        }
        catch(Exception e)
        {
            Errlog.add(__CLASS__+": request parse fail");
            return "{\"errcode\":\""+SOAR_ERR.MSG+"\"}";
        }

        try
        {
            HashMap m=new HashMap();
            m.put("errcode", SOAR_ERR.OK);
            m.put("msg", msg);
            m.put("size", msg.length());
            return  JSONObject.fromObject(m).toString();
        }
        catch(Exception e)
        {
            Errlog.add(__CLASS__+": response form fail");
            return "{\"errcode\":\""+SOAR_ERR.MSG+"\"}";
        }
    }
}
